@include('admin.public.head')
<link href="{{ URL::asset('./admin/css/main.css') }}" rel="stylesheet">
<style>
* {
    -webkit-box-sizing: initial;
    box-sizing: initial;
}
.wrapper h2 {height: 35px;line-height: 35px;font-size: 15px;border-bottom: 1px solid #e7eaec;}
</style>
<body class="gray-bg">
	<form action="" method="post" enctype="multipart/form-data" id="brandForm">
	<input type="hidden" name="id" value="{{$id}}"/>
     <section class="page wrapper wrapper-content animated fadeInRight">
      <h2><strong>管理员编辑</strong></h2>
      <ul class="ulColumn2">
       <li>
        <span class="item_name" style="width:120px;">管理员账号：</span>
        <input type="text" value="{{$res->account}}" readonly class="textbox textbox_295" name="account" id="account" placeholder="管理员账号..."/>
       </li>
		  <if condition="$res.id neq 1">
		  <li>
			  <span class="item_name" style="width:120px;">管理员角色：</span>
			  <select name="role_id" id="" class="textbox textbox_295" style="height: 35px" >
			  	@foreach ($list as $vo)
					  	<option value="{{$vo->role_id}}" @if($res->role_id == $vo->role_id)selected="selected"@endif>{{$vo->role_name}}</option>
				@endforeach
			  </select>
		  </li>
		  </if>
	   <li>
        <span class="item_name" style="width:120px;">管理员密码：</span>
        <input type="password" value="" class="textbox textbox_295" name="pwd" id="passwd" placeholder="默认为旧密码"/>
       </li>


	   <li>
        <span class="item_name" style="width:120px;">确认密码：</span>
        <input type="password" value="" class="textbox textbox_295" name="repasswd" id="repasswd" placeholder="默认为旧密码"/>
       </li>

	   <li>
        <span class="item_name" style="width:120px;">真实姓名：</span>
        <input type="text" value="{{$res->real_name}}" class="textbox textbox_295" name="real_name" id="real_name" placeholder="真实姓名..."/>
       </li>
       <li>
        <span class="item_name" style="width:120px;"></span>
        <input type="button" class="link_btn button" value="提交"/>
       </li>
      </ul>
     </section>
	 </form>

     <!--tabStyle-->
     <script type="text/javascript">
	    $(document).ready(function(){
			 $(".admin_tab li a").click(function(){
				  var liindex = $(".admin_tab li a").index(this);
				  $(this).addClass("active").parent().siblings().find("a").removeClass("active");
				  $(".admin_tab_cont").eq(liindex).fadeIn(150).siblings(".admin_tab_cont").hide();
			 });

			 $(".button").click(function(){

				if($("#account").val()==""){
					layer.msg("管理员账号不能为空!");
					return false;
				}

				if($("#passwd").val()!=$("#repasswd").val()){
					layer.msg("两次密码不一样!");
					return false;
				}

				if($("#real_name").val()==""){
					layer.msg("真实姓名不能为空!");
					return false;
				}


				var form = $("#brandForm").serialize();

				$.ajax({
	                url:"/edit_do",    //请求的url地址
	                dataType:"json",   //返回格式为json
	            	data:form,
	                type:"POST",   //请求方式
	                success:function(req){
	                    //请求成功时处理
	                    if(req.status == 0){
	                        layer.msg(req.message);
	                        return false;
	                    }


	                    layer.msg('操作成功！');
		                setTimeout(function(){
		                    window.location.href = "/admin_li";
		                },500);
	                }
	            });

				return false;
			 });

		});
     </script>
</body>
</html>
